package com.view.componet;


import com.controller.LoginController;
import com.util.Session;
import com.vaadin.ui.Button;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.MenuBar.Command;
import com.vaadin.ui.MenuBar.MenuItem;

/**
 * Class Header: Classe tem componentes correspondentes a parte superior da tela.
 * @author Ricardo
 */

public class Header extends CssLayout {
  
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private MenuBar menubar = new MenuBar();
	private CssLayout left;
	/**
	 * Construtor cria os componentes 
	 * @author Ricardo
	 */
	  private LoginController loginController;
		
	public Header(LoginController loginController) {
	       this.loginController = loginController;

		//Define propor�‹o da tela e estilo
		setWidth("100%");
		addStyleName("toolbar-invert");

		//Parte que fica a esquerda
		//Nome da aplica�‹o e menus superiores
		
		CssLayout left = new CssLayout();
		left.setSizeUndefined();
		left.addStyleName("left");
		addComponent(left);
		
		//Define o nome da aplica�‹o
		Label title = new Label("Gerenciamento Despesas");
		title.addStyleName("h1");
		left.addComponent(title);

		//
		Label user = new Label("User: "+ Session.getInstance().getUsuario().getNome());
		title.addStyleName("left");
		left.addComponent(user);

		//Parte que fica a direita
		//Login
		//
		
		CssLayout right = new CssLayout();
		right.setSizeUndefined();
		right.addStyleName("right");
		addComponent(right);
	
		//Bot‹o para confirmar o login
		Button login = new Button("Logoff",new Button.ClickListener() {
            // inline click-listener
            public void buttonClick(ClickEvent event) {
            	 logoOff();
            }
        });
		login.addStyleName("border-normal");
		right.addComponent(login,0);
		
   }
	
	public void logoOff(){
		
		 this.loginController.LogoOff();
	}
	
	  private Command menuCommand = new Command() {
		
		public void menuSelected(MenuItem selectedItem) {
			// TODO Auto-generated method stub
			
		}
	};
}
